spitoi2c 2.2.0
Loading...
Searching...
No Matches
main.c File Reference

SPI to I2C Click example. More...

#include "board.h"
#include "log.h"
#include "spitoi2c.h"

Macros

#define DEVICE_NAME   "3D Hall 11 Click"
#define DEVICE_SLAVE_ADDRESS   0x35
#define DEVICE_REG_MAN_ID   0x0E
#define DEVICE_MAN_ID_0   0x49
#define DEVICE_MAN_ID_1   0x54

Functions

void application_init (void)
void application_task (void)
int main (void)

Detailed Description

SPI to I2C Click example.

Description

This example demonstrates the use of SPI to I2C Click board by reading the manufacturer ID of a 3D Hall 11 Click board connected to the I2C port and controlling the GPIO pins.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default config which enables the device and sets the GPIO pins 0-2 as push-pull output and others as input. Then sets the I2C clock to 99KHz, I2C address to 127 and disables I2C timeout. After that, reads and displays the chip firmware version.

Application Task

Reads the manufacturer ID of a 3D Hall 11 Click board connected to the I2C port, toggles the output pins and displays the GPIO port state. The results will be displayed on the USB UART approximately once per second.

Author
Stefan Filipovic

Macro Definition Documentation

◆ DEVICE_MAN_ID_0

#define DEVICE_MAN_ID_0   0x49

◆ DEVICE_MAN_ID_1

#define DEVICE_MAN_ID_1   0x54

◆ DEVICE_NAME

#define DEVICE_NAME   "3D Hall 11 Click"

◆ DEVICE_REG_MAN_ID

#define DEVICE_REG_MAN_ID   0x0E

◆ DEVICE_SLAVE_ADDRESS

#define DEVICE_SLAVE_ADDRESS   0x35

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )